<?php
//用户首页
use App\Models\Member;
use App\Models\Merchant\GiftLog;

Route::get('index','ParkInfoController@index');
//某的车位
Route::get('parkings/{id?}','ParkInfoController@parkingList');
//升级车位
Route::post('parking/upgrade','ParkInfoController@upgrade');
//获取车辆
Route::get('cars/{user_id?}','CarController@index');


Route::group(['prefix'=>'store'],function(){
    //商城-车辆
    Route::get('cars','StoreController@cars');
    //商城-道具
    Route::get('items','StoreController@stages');
    //购买车辆
    Route::post('buy/car','StoreController@buyCar');
    //购买道具
    Route::post('buy/stage','StoreController@buyStage');
    
});

Route::group(['prefix'=>'car'],function(){
    //使用道具
    Route::post('stage','StageController@useStage');
    //领取收益
    Route::post('back','CarController@backCar');
    //缴纳罚金
    Route::post('forfeit','CarController@forfeit');
    //停车
    Route::post('stop','CarController@stopCar');
    //贴条
    Route::post('punish','CarController@punish');
    //卖车
    Route::post('sell','CarController@sell');
});

//更多消息
Route::get('messages','MessageController@more');
//获取陌生人列表
Route::get('users','UserController@strangers');
//用户等级升级
Route::post('user/upgrade','UserController@upgradeLevel');
//获取好友列表
Route::get('friends','FriendController@friends');
//添加好友
Route::POST('friend/add','FriendController@addFriend');
//寻找车位
Route::get('parking/search','FriendController@search');
//获取我的道具
Route::get('stages','StageController@mine');

Route::group(['prefix'=>'gold_shop'],function(){
    //获取所有的金币对积分数据列表
    Route::get('list','GoldShopController@goldShopList');
    //积分抽奖，并返回结果
    Route::get('lottery','GoldShopController@lottery');
});

Route::group(['prefix'=>'draw_lots'],function(){
    Route::get('index','DrawLotsController@drawLots');
    Route::post('drawLots','DrawLotsController@signIn');
    Route::get('card','DrawLotsController@card');
    Route::get('draw_card','DrawLotsController@draw_card');
    Route::get('rewards','DrawLotsController@rewards');
    Route::get('card_series','DrawLotsController@card_series');

});

//用户签到状态
Route::get('sign_status','DrawLotsController@sign_status');
//减扣金币接口
Route::get('decrementUserGold','DrawLotsController@decrementUserGold');
//增加金币接口
Route::get('incrementUserGold','DrawLotsController@incrementUserGold');
//新增用户接口
Route::get('addUser','DrawLotsController@add_user');


//神秘商人
Route::group(['prefix'=>'merchant'],function(){
    //首页
    Route::get('index','MerchantController@index');
    //抽奖
    Route::post('lottery','MerchantController@lottery');
    //兑换
    Route::post('lottery/exchange','MerchantController@exchange');
    //我的礼物
    Route::get('mine','MerchantController@mine');
    //抽奖记录
    Route::get('logs','MerchantController@logs');
    //神秘商人开启状态判断
    Route::get('open_status',function(){
        $config = config('car.merchant_config');
        $current_hour = date('G');
        $begin_hour = $config['begin_hour'];
        $end_hour = $config['end_hour'];
        $is_open = (int)($current_hour >= $config['begin_hour'] && $current_hour <= $config['end_hour']);
        return compact('is_open','begin_hour','end_hour');
    });
    
    //填写地址
    Route::post('info','MerchantController@info');
});

//对外接口，统计游戏人数
Route::get('gamers',function(){
    $car_gamers = Member::count();
    $merchant_gamers = GiftLog::distinct('user_id')->count('user_id');
    return compact('car_gamers','merchant_gamers');
});

